<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Location Edit</title>
<LINK REL="stylesheet" HREF="CSS/Main.css" TYPE="text/css">
<LINK REL="stylesheet" HREF="CSS/Button.css" TYPE="text/css">
</head>
<body>

	<div id="top">
		<h1>Master Data Management</h1>
		<br>
		<a id="log" href="logout">Logout</a><br>
    		<%@ include file="redirection.jsp" %>
		<div id="menu">
	      <ul>
	        <li>
	        	<form action = "logout" method="post">
					<a><input type="submit" name="Logout" value="Logout"></a>
				</form>
			</li>
	      </ul>
	    </div>
	</div>

	<h2>Location View/Edit</h2>
	
	<div id="left">
		<div class="box">
		
				<%
					String[] loc = (String[]) request.getAttribute("location");
					if (loc == null) {
				%>
				<form name='header' action='LocationEdit' method="get">
					<script type="text/javascript">
						document.forms['header'].submit();
					</script>
				</form>
				<%
					}
				%>
			
				<form action="LocationEdit" method="get">
					<table><tr><td>
							<select name="selected">
								<%if(loc!=null){
									for(String s:loc){%>
										<option value="<%=s%>"><%=s%></option>
								<%}}%>
							</select> 
						</td>
						<td>
							<input type="submit" class="button" name="show" value="Show Details">
						</td>
					</tr></table>
				</form>

		</div>
		<div class="visbox">
		<table>
			<tr>
			<td>
				<form action="ControlPanel.jsp">
					<input type="submit" class="button" name="Back" value="Back">
				</form>
			</td><td>
				<%if(session.getAttribute("role").equals("admin")){%>
				<form action="Home.jsp">
					<input type="submit" class="button"name="Home" value="Home">
				</form>		
			<%}else{%>
				<form action="HomeUser.jsp">
					<input type="submit" class="button"name="Home" value="Home">
				</form>	
			<% }%>			
			</td>
			</tr>
		</table>
		</div>
	</div>
	<div id="right">
		<form action="LocationEdit" method="post">
			<%	String[] details = (String[]) request.getAttribute("Locdetails");
				if (details != null) {  %>	
				<table border="1" width="600">
				<tr>
					<td>Location Name</td>
					<td>Description</td>
					<td>Flag</td>
				</tr>
				<tr>
					<td><input type="hidden" name="LocationName" value="<%=details[0]%>"><%=details[0]%></td>
					<td><input type="text" name="Description" value="<%=details[1]%>"></td>
					
					<td><input type="hidden" name="oldFlag" value="<%=details[2]%>">
						<select name="SelectFlag">	
							<% if(details[2].equals("N")){ %>
								<option value="N" selected>No</option>
								<option value="Y">Yes</option>
							<% 	}
								else{%>
									<option value="N">No</option>
									<option value="Y" selected>Yes</option>
								<%}%> 
						</select>
					</td>
				</tr>
				</table>
					<br>
				<input type="submit" class="button" name="edit" value="Edit">
				<%} %>
			
		<br>
		</form>
		<article><%=(request.getAttribute("status")==null) ? "":request.getAttribute("status")%></article>
	</div>
	<br>
	

</body>
</html>